/*
 * Created by JFormDesigner on Tue Jul 09 10:31:14 CST 2024
 */

package com.hongyan.view;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import com.hongyan.base.BaseContentJpanel;
import com.hongyan.base.BaseJpanel;
import com.hongyan.bean.Admin;
import com.hongyan.bean.Student;
import com.hongyan.bean.Teacher;
import com.hongyan.config.MainFrameConfig;
import com.hongyan.dialog.SwingTeacherTestWorkAddDialog;
import com.hongyan.main.SwingMainFrame;


import static com.hongyan.config.MainFrameConfig.getSwingMainFrame;

/**
 * @author admin
 */
public class SwingLogoutPanel extends BaseContentJpanel {

    private void login(ActionEvent e) {
        // TODO add your code here
    }
    @Override
    public void initListen() {
        button1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                getSwingMainFrame().dispose();

                SwingMainFrame swingMainFrame = new SwingMainFrame();
                MainFrameConfig.setSwingMainFrame(swingMainFrame);
                SwingLoginPanel swingLoginPanel = new SwingLoginPanel(swingMainFrame);
                swingMainFrame.replacePanel(swingLoginPanel);
            }
        });

    }



    @Override
    public void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        label1 = new JLabel();
        button1 = new JButton();

        //======== this ========
        setLayout(null);

        //---- label1 ----
        label1.setText("\u8f6f\u4ef6\u6d4b\u8bd5\u7ba1\u7406\u7cfb\u7edf");
        label1.setFont(new Font("\u6977\u4f53", Font.PLAIN, 18));
        add(label1);
        label1.setBounds(new Rectangle(new Point(265, 205), label1.getPreferredSize()));

        //---- button1 ----
        button1.setText("\u9000\u51fa\u767b\u5f55");
        button1.addActionListener(e -> login(e));
        add(button1);
        button1.setBounds(290, 295, 103, 45);

        {
            // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < getComponentCount(); i++) {
                Rectangle bounds = getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            setMinimumSize(preferredSize);
            setPreferredSize(preferredSize);
        }
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    @Override
    public void initData() {

    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JLabel label1;
    private JButton button1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
